﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using OA.DBUtility;
using OA.Model;
using System.Collections.Generic;

namespace OA.Manager
{
    /// <summary>
    /// 数据访问类:ProjectPrize
    /// </summary>
    public partial class ProjectPrizeManager : ManagerParent<ProjectPrizeInfo>
    {
        private SqlService<ProjectPrizeInfo> _sqlService = null;

        public ProjectPrizeManager()
        {
            _sqlService = new SqlService<ProjectPrizeInfo>();
        }

        #region  Method

        /// <summary>
        /// 插入新记录
        /// </summary>
        /// <param name="projectPrizeInfo"></param>
        /// <returns></returns>
        public bool InsertProjectPrizeInfo(ProjectPrizeInfo projectPrizeInfo)
        {
            return _sqlService.SaveEntity(projectPrizeInfo);
        }

        /// <summary>
        /// 根据打印任务ID获得打印任务信息
        /// </summary>
        /// <param name="taskID"></param>
        /// <returns></returns>
        public ProjectPrizeInfo GetProjectPrizeInfoByID(int ID)
        {
            Dictionary<string, object> dic = new Dictionary<string, object>();
            dic.Add("ID", ID);
            return _sqlService.GetSingleByFields(dic, null);
        }


        public DataTable GetPaged(int pageIndex, int pageSize, ref int total)
        {
            return _sqlService.GetPaged("*", "", pageIndex, pageSize, ref pageSize, ref total);
        }

        public DataTable GetSearchPaged(ProjectPrizeInfo info, int pageIndex, int pageSize, ref int total)
        {
            return _sqlService.GetSearchPaged(info, pageIndex, pageSize, ref total);
        }

        /// <summary>
        /// 判断该打印任务是否存在
        /// </summary>
        /// <param name="projectPrizeInfo"></param>
        /// <returns></returns>
        public bool IsExistProjectPrizeInfo(ProjectPrizeInfo projectPrizeInfo)
        {
            return _sqlService.IsExist(projectPrizeInfo);
        }

        /// <summary>
        /// 根据指定的字段更新，字段名是数据库中对应的名称
        /// </summary>
        /// <param name="projectPrizeInfo"></param>
        /// <param name="needUpdateFields"></param>
        /// <returns></returns>
        public bool UpdateProjectPrizeInfo(ProjectPrizeInfo projectPrizeInfo, List<string> needUpdateFields)
        {
            return _sqlService.UpdateByFields(projectPrizeInfo, needUpdateFields);
        }

        /// <summary>
        /// 删除该检查任务
        /// </summary>
        /// <param name="projectPrizeInfo"></param>
        /// <returns></returns>
        public bool DeleteProjectPrizeInfo(ProjectPrizeInfo projectPrizeInfo)
        {
            return _sqlService.DeleteEntity(projectPrizeInfo);
        }

        #endregion  Method
    }
}

